"""
机器信息相关模型
"""
from pydantic import BaseModel
from typing import Optional
from datetime import datetime

class MachineBase(BaseModel):
    """机器基础模型"""
    name: str
    ip: str
    os: Optional[str] = ""
    purpose: Optional[str] = ""
    owner: Optional[str] = ""
    location: Optional[str] = ""

class MachineCreate(MachineBase):
    """创建机器模型"""
    pass

class MachineUpdate(BaseModel):
    """更新机器模型"""
    name: Optional[str] = None
    ip: Optional[str] = None
    monitor_config: Optional[str] = None
    os: Optional[str] = None
    purpose: Optional[str] = None
    owner: Optional[str] = None
    location: Optional[str] = None
    status: Optional[str] = None
    is_activate: Optional[bool] = None

class Machine(MachineBase):
    """机器模型"""
    id: int
    status: str
    cpu: int
    memory: int
    disk: int
    uptime: Optional[str] = None
    last_reboot: Optional[datetime] = None
    is_activate: Optional[bool] = True
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True